//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo_2353;

import java.util.ArrayList;
import java.util.List;

public class FoodRatings {
    String[] foods;
    String[] cuisines;
    int[] ratings;

    public FoodRatings(String[] foods, String[] cuisines, int[] ratings) {
        this.foods = foods;
        this.cuisines = cuisines;
        this.ratings = ratings;
    }

    public void changeRating(String food, int newRating) {
        for(int i = 0; i < this.foods.length; ++i) {
            if (this.foods[i].equals(food)) {
                this.ratings[i] = newRating;
                break;
            }
        }

    }

    public String highestRated(String cuisine) {
        List<Integer> list = new ArrayList();

        for(int i = 0; i < this.cuisines.length; ++i) {
            if (this.cuisines[i].equals(cuisine)) {
                list.add(i);
            }
        }

        int max = (Integer)list.get(0);

        for(int i = 1; i < list.size(); ++i) {
            if (this.ratings[(Integer)list.get(i)] > this.ratings[max]) {
                max = (Integer)list.get(i);
            }

            if (this.ratings[(Integer)list.get(i)] == this.ratings[max] && this.foods[max].compareTo(this.foods[(Integer)list.get(i)]) > 0) {
                max = (Integer)list.get(i);
            }
        }

        return this.foods[max];
    }
}
